import numpy as np
import cv2
from matplotlib import pyplot as plt

img = cv2.imread('misc_pic/test.jpg',0)

#使用默认值初始化FAST对象
fast = cv2.FastFeatureDetector_create()
#寻找并绘制关键点
kp = fast.detect(img,None)
img2 = cv2.drawKeypoints(img,kp,outImage=img,color=(255,0,0))
# Print all default params
print("Threshold:",fast.getThreshold())
print("nonmaxSuppression:", fast.getNonmaxSuppression())
print("neighborhood:", fast.getType())
print("Total Keypoints with nonmaxSuppression:",fast.descriptorSize())

# Disable nonmaxSuppression
#fast.setBool('nonmaxSuppression',0)
#kp = fast.detect(img,None)
#print("Total Keypoints without nonmaxSuppression: %d", len(kp))
#img3 = cv2.drawKeypoints(img, kp, color=(255,0,0))

cv2.imshow('FAST_keypoints',img2)
while(True):
    if cv2.waitKey() & 0xff ==ord("q"):
        break
cv2.destroyAllWindows()